<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSS3实现小鸟飞翔动画DEMO演示</title>

<script type="text/javascript" src="js/jquery.min.js"></script>

<style type="text/css">
*{
	margin: 0;
	padding: 0;
}
html,body,.box{
	width: 100%;
	height: 100%;
	overflow: hidden;
}
body{
	background-image: url("images/back2.jpg");
	background-size: 100% 100%;
}
.box .bird{
	width: 141px;
	height: 85px;
	background-image: url(images/bird.png);
	animation: bird 1s steps(1) infinite ;
	-webkit-animation: bird 1s steps(1) infinite ;
	-o-animation: bird 1s steps(1) infinite ;
	-ms-animation: bird 1s steps(1) infinite ;
	-moz-animation: bird 1s steps(1) infinite ;
}

@keyframes bird
{
	0%    {background-position: -0 0;}
	12.5% {background-position: -141px 0;}
	25%   {background-position: -282px 0;}
	37.5% {background-position:  -423px 0;}
	50%   {background-position:  -564px 0;}
	65.7% {background-position:  -705px 0;}
	75%   {background-position:  -846px 0;}
	87.5% {background-position:  -987px 0;}
	100%  {background-position:  -1128px 0;}

}
</style>

</head>
<body>

<div class="box">
	<div class="bird" id="birds"></div> 
</div>

<script type="text/javascript">
		var speed=50;
		var birds=document.getElementById("birds");
		var boxs=document.getElementsByClassName("box")[0];
		var width=boxs.offsetWidth;
		var point=true;
		var times=setInterval(function () {
			if(point){
				birds.style["margin-left"]=speed+"px";
				birds.style["transform"]='rotateY(0deg)';
				point=(speed+birds.offsetWidth+40)>width?false:true;
				speed+=10;
			}else {
				speed-=10;
				birds.style["margin-left"]=speed+"px";
				birds.style["transform"]='rotateY(180deg)';
				point=0>(speed-birds.offsetWidth)?true:false;
			}
		},100);
</script>

</div>
</body>
</html>
